<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/jquery-select2/3.4/select2.min.css" rel="stylesheet" />
	<link rel="stylesheet" href='${ctxStatic}/jiu/css/hoverbox.css' type="text/css" media="screen, projection" />
	<script src="https://select2.github.io/vendor/js/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".js-example-basic-single").select2();
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
	
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jiujiu/jiuCommodity?classId=${jiuCommodity.classId}">商品列表</a></li>
		<shiro:hasPermission name="jiujiu:jiuCommodity:edit"><li><a href="${ctx}/jiujiu/jiuCommodity/form?classId=${jiuCommodity.classId}&cid=${jiuCommodity.classId}">商品添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="jiuCommodity" action="${ctx}/jiujiu/jiuCommodity/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>名称 ：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
		
		<label>所属分类 ：</label>
		<form:select path="classId" class="js-example-basic-single">
			<form:option value="">全部</form:option>
			<c:forEach items="${jiuCommodityClassList}" var="jiuCommodityClass">
                   <form:option value="${jiuCommodityClass.id}">${jiuCommodityClass.name}</form:option>
			</c:forEach>
       	</form:select>
       	
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>商品名称</th>
		<th>分类名称</th>
		<th>图标</th>
		<th>首页商品排序 </th>
		<th>推荐商品排序 </th>
		<th>分类商品排序 </th>
		<th>价格</th>
		<th>单位</th>
		<th>是否显示</th>
		<th>是否推荐</th>
		<shiro:hasPermission name="jiujiu:jiuCommodity:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		
		<c:forEach items="${page.list}" var="commodity">
			<tr>
				<td>${commodity.name}</td>
				<td>${commodity.className}</td>
				<td>
				 <div class="hoverbox">
				  <a href="#">
				  <img src="${ctxUser }/jiu/${commodity.ico}" alt="" />
				<img src="${ctxUser }/jiu/${commodity.ico}" alt="" class="preview" />
				  </a>
				  </div>
				</td>
				<td>${commodity.sortHomePage}</td>
				<td>${commodity.sort}</td>
				<td>${commodity.sortClass}</td>
				<td>${commodity.price}</td>
				<td>${commodity.unit}</td>
				<td>${commodity.isShow eq 0?'不显示':'显示'}</td>
				<td>${commodity.isRecommend eq 0?'否'	:'是'}</td>
				<shiro:hasPermission name="jiujiu:jiuCommodity:edit"><td>
    				<a class="btn btn-success" href="${ctx}/jiujiu/jiuCommodity/form?id=${commodity.id}&classId=${commodity.classId}&cid=${jiuCommodity.classId}">修改</a>
    				<a class="btn btn-success" href="${ctx}/jiujiu/jiuCarousel?type=2&commodityId=${commodity.id}">轮播管理</a>
					<c:set var="isDel" value="${fn:indexOf(fns:getUser().roleIdList, '10') == -1}" scope="page"/>
					<c:if test="${isDel }">	<!-- 平台客服  无权删除 -->
						<a class="btn btn-danger" href="${ctx}/jiujiu/jiuCommodity/delete?id=${commodity.id}&classId=${jiuCommodity.classId}" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
					</c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	<div class="pagination">${page}</div>
</body>
</html>
